package com.lxj.array_list;

import java.util.ArrayList;
import java.util.Arrays;

import com.lxj.charactor.Hero;

/**
 * TestCollection
 */
public class TestCollection {

    public static void main(String[] args) {
        ArrayList heros = new ArrayList();
        // heros.add(new Hero("gai lun"));

        // System.out.println(heros.size());

        // heros.add(new Hero("提莫"));
        // System.out.println(heros.size());

        for (int i = 0; i < 5; i++) {
            heros.add(new Hero("hero_"+i));
        }
        // System.out.println(heros);

        // 判断一个对象是否存在于heros
        // System.out.println(heros.contains(new Hero("hero_1")));

        Hero sh = new Hero("special hero");
        heros.add(sh);
        
        // System.out.println(heros.get(4));

        // System.out.println(heros.indexOf(sh));

        System.out.println(heros.size());

        heros.remove(2);
        System.out.println(heros.size());

        Hero[] hs = (Hero[]) heros.toArray(new Hero[]{});

        System.out.println(Arrays.toString(hs));


    }
}